﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="head.ascx.cs" Inherits="head" %>
<ul class="mininav">
 <li class="of-ot-oznt-01"><a style="display:none" id="member_username" href="member_center.aspx" target="_blank"></a>&nbsp;欢迎您来到壹佰商城&nbsp;<a id="login" href="login.aspx" class="LineR">请登录</a> &nbsp;<a id="registe" href="login.aspx">[免费注册]</a>&nbsp;<a id='logout' style="display:none; cursor:pointer">[退出]</a></li>
 <li class="of-ot-oznt-02"><a href="member_center.aspx" class="LineR">会员管理</a><a href="member_center.aspx" class="LineR">超级积分俱乐部</a><a id="shoppingCart" href="shoppingCart.aspx" class="LineR">购物车</a><a href="favorite.aspx" class="LineR">收藏夹</a><a href="help.aspx" class="LineR">帮助中心</a> &nbsp;销售热线：<img src="images/icon-003.gif" alt="400-678-1128" /></li>
</ul>
<!-- /end mininav -->
<div class="header">
 <h1 class="logo"><a href="/"><img src="images/icon-000.gif" alt="壹佰商城" /></a></h1>
 <!-- /end logo -->
 <ul class="SearchForm">
  <li class="pf-th-otz">关键字：</li>
  <li class="textarea1"><input name="txtKeyword" id="txtKeyword" runat="server" class="textarea" type="text" /></li>
  <li class="pf-th-otz">价格从</li>
  <li class="textarea2"><input name="txtMaxPrice" id="txtMinPrice" runat="server" class="textarea" type="text" /></li>
  <li class="pf-th-otz">到</li>
  <li class="textarea2"><input name="txtMinPrice" id="txtMaxPrice" runat="server" class="textarea" type="text" /></li>
  <li class="textarea3"><input name="btnSearch" id="btnSearch" class="butarea" type="button" value="搜索" /></li>
  <li class="pf-th-otz"><a href="#"></a></li>
 </ul>
 <!-- /end SearchForm -->
 <ul class="navigation">
  <li><a href="default.aspx"><span>首页</span></a></li>
  <li><a href="p_list.aspx?isNew=1"><span>最新商品</span></a></li>
  <li><a href="p_list.aspx?categoryId=544"><span>瓷砖·陶瓷</span></a></li>
  <li><a href="p_list.aspx?categoryId=543"><span>地板·天花</span></a></li>
  <li><a href="p_list.aspx?categoryId=542"><span>卫浴·洁具</span></a></li>
  <li><a href="p_list.aspx?categoryId=541"><span>橱柜·衣柜</span></a></li>
  <li><a href="p_list.aspx?categoryId=540"><span>油漆·涂料</span></a></li>
  <li><a href="p_list.aspx?categoryId=539"><span>门窗·灯饰</span></a></li>
  <li><a href="p_list.aspx?categoryId=537"><span>五金·电器</span></a></li>
  <li><a href="news_list.aspx?categoryId=7"><span>团购专区</span></a></li>
 </ul>
 <!-- /end navigation -->
 <ul class="navigationde">
  <li><a href="p_show.aspx?productId=33" target="_blank">浴室柜</a></li>
  <li><a href="p_show.aspx?productId=28"  target="_blank">台盆</a></li>
  <li><a href="p_show.aspx?productId=19" target="_blank">玉兰墙纸</a></li>
  <li><a href="p_show.aspx?productId=16" target="_blank">永高壁纸</a></li>
 </ul>
 <!-- /end navigationde -->
</div>
<!-- /end header -->
<script src="js/common.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#btnSearch').bind('click', function() {
            var keyword = $.trim($('#head1_txtKeyword').val());
            var maxPrice = $.trim($('#head1_txtMaxPrice').val());
            var minPrice = $.trim($('#head1_txtMinPrice').val());
            var query = [];
            var queryUrl = "";
            if (keyword.length > 0)
                query.push("keyword=" + keyword);
            var numberReg = /^\d+$/;
            if (minPrice.length > 0) {
                if (!numberReg.test(minPrice)) {
                    alert("最低价格必须为数字");
                    return false;
                } else {
                    query.push("minPrice=" + minPrice);
                }
            }
            if (maxPrice.length > 0) {
                if (!numberReg.test(maxPrice)) {
                    alert("最高价格必须为数字");
                    return false;
                } else {
                    query.push("maxPrice=" + maxPrice);
                }
            }

            queryUrl = query.join('&');
            var param = GetRequestUrlParam();
            //alert(url);
            window.location.href = 'p_list.aspx?' + param + queryUrl;
        });
        var username = getCookie('eshop_userName');
        if (username != null) {
            $('#member_username').html('<font color=red><strong>' + username + '</strong></font>');
            $('#member_username').show();
        } else {
            $('#member_username').hide();
        }
        var isLogin = getCookie('eshop_isLogin');
        if (isLogin != null && isLogin == "yes") {
            $('#logout').show();
            $('#login').hide();
            $('#registe').hide();
            $('#logout').bind('click', function() {
                delCookie('eshop_isLogin');
                $(this).hide();
                window.location.href = 'login.aspx';
            });
        } else {
            $('#logout').hide();
            $('#login').show();
            $('#registe').show();
        }
        var shoppingCart = getCookie('eshop_shoppingCart');
        if (shoppingCart != null) {
            var iMatCount = 0;
        var str = new Array();
        str = shoppingCart.split(",");
        for (i = 0; i < str.length; i++) {
            iMatCount += parseInt(str[i].split("|")[1]);
        }
        $('#shoppingCart').html('购物车(<font color=red><strong>' + iMatCount + '</strong></font>)');
         }
        

    });

    function GetRequestUrlParam() {
        var urlParam="";
        var url = location.search; //获取url中"?"符后的字串
        var Longurl = location.href; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {            
            if (Longurl.indexOf("p_list") != -1) {
                var str = url.substr(1);              
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    if (strs[i].split("=")[0] == "keyword" || strs[i].split("=")[0] == "minPrice" || strs[i].split("=")[0] == "maxPrice") {

                    } else {                    
                        if (strs[i].split("=")[0] != undefined) {
                            urlParam += strs[i].split("=")[0] + "=" + strs[i].split("=")[1] + "&";
                        }
                        
                    }
                }
                //urlParam = urlParam.substr(0, urlParam.length - 1);
            }
        }

        return urlParam;
 
    }

</script>